This invention relates to a method for merging images. In particular, the invention relates to a method implemented in a printing device for merging a user-input image and a stored template image into a merged image for printing.
Printers today are able to print at high resolution on a variety of media. For example, some printers are able to print at resolution of up to 1200 dots per inch (dpi) on photo-quality paper to produce printouts of a quality comparable to developed photographs. Some of these printers include a feature for merging a user-input image with a selected template image to produce a merged image printout, which is otherwise not easily achievable with standard photographs. This merging of images feature allows novice users to create fanciful printouts of their choice easily and economically.
FIG. 1 shows a prior art method for combining a user image 2 and a template image 4 to produce a merged image 6 by defining cutout portions, such as a portion 8, in the template image 4. Portions of the user image 2 which spatially corresponds to the cutout portion 8 are used to fill-in the cutout portion 8 to produce the merged image 6. The pixel values in the cutout portion 8 in the template image 4 are identified by a unique value. During merging, each pixel in the template image 4 is examined in turn. If the value of a template pixel is equal to the unique value, a spatially corresponding pixel in the merged image will take the value of a spatially corresponding pixel in the user image. Otherwise, the pixel in the merged image will take the value of the template pixel. An example of a unique value is a specific pixel value for black.
In a configuration where a printer is connected to a computer, the image-merging feature can be performed in either the printer or the computer. The template images can be stored accordingly. To store a template image of a physical size of 3.5xe2x80x3 by 5.5xcex94 at a resolution of 300 dpi, with each pixel being represented by 3 bytes of data, a total of 5.2 mega-bytes (MB) of memory is conventionally needed. This memory size is large and is therefore prohibitively costly for any printer targeted at home users. Furthermore, such an image-merging feature would only be appealing if several template images are made available. These template images can be stored on a computer where memory is usually more abundant than available on a printer. This storing of template images on a computer would render image merging to be most appropriately performed on the computer with a resultant merged image being sent to the printer for printing. Using such a method of image merging will require that an image captured on digital equipment such as digital cameras, photo scanners and digital recorders, be loaded onto the computer and merged with the template image in the computer before any printing is possible. It would be advantageous to bypass the computer and have the digital equipment directly load a captured image onto a printer and have the printer merge the captured image with a locally-stored template image for printing. Incidentally, the template images should be efficiently stored on the printer to minimize the memory requirement to support such an image-merging feature.
One possible way to reduce the memory requirement for storage of template images is to compress the template images. However, many existing compression methods, such as the JPEG compression standard, are lossy. In the JPEG compression, data is shed to give a smaller image data size at the expense of image quality. Even with such compression, which can reduce the amount of memory required to about one-tenth of that required to store a raw image, about 500 kilo-bytes (KB) is still required for each template image. This memory size is still large by any standard. Storing the template images at a lower resolution, for example at 100 dpi instead of 300 dpi, helps in reducing memory requirement. A compressed template of size of about 50K is achievable. However, this lower resolution template image will result in disadvantages during reproduction. Firstly, the template image will need to be scaled back up to 300 dpi in a process which will consume processor time and therefore reduce overall printing speed. The scaling up of the template image will result in what is known as a gray-edge phenomenon, where a grayish outline appears along the edges of objects in an image. Secondly, a reproduction of a highly compressed image results in compression artifacts 7. Such artifacts appear both in the cutout regions and other regions in the template image. The artifacts 7 in the cutout portions 8 will remain in the merged image 6 to result in a reduced quality merged image 6.
A commonly used compression technique that does not result in compression artifacts is the Run Length Encoding (RLE) method. This method works well for encoding a continuous run of a same byte, such as the black values used to define the cutout portions. Typically, cutout regions occupy about three quarters of a template image. These three quarters of the template image can be effectively compressed using RLE. However, the remaining quarter which holds template objects in the template image is still of considerable 1.3 MB for a 5.2 MB template image. By today""s standard, a memory of this size is too costly to be included into a consumer product if cost is a concern. Although compression artifacts are avoided when using RLE, the same level of compression achievable with JPEG compression cannot be attained. As such JPEG compression of a template image remains a better choice if the size of a compressed template image is a concern.
The foregoing therefore creates the need for a method of merging a template image which is highly compressed with a user image to produce a merged image which is relatively free of compression artifacts.
In one aspect, the present invention may be implemented as a method for merging two or more images to produce a merged image using a mask. Each of the images has mutually corresponding pixels. In other words, each pixel value in an image has a spatially corresponding pixel in the other images. The mask has mask values, each mask value corresponding to a pixel in an image. The mask value is used to determine the corresponding pixel value of the merged image. One embodiment uses this mask value to set a corresponding pixel value of the merged image to one a corresponding pixel value in one of the images. Another embodiment uses the mask value as a weight. This weight is used to calculate the pixel value as a combination of corresponding pixel values of the images.
By using such a mask, a merged image may be formed without artifacts resulting from decompressing a highly compressed image.
In another aspect, a system for merging two or more images according to a preferred embodiment of the invention includes a mask and an image generator. The mask has values for determining the composition of a merged image. The image generator generates the merged image in accordance with the mask values. The mask values are derived from attributes in at least one of the two or more images for identifying in the images a background and image portions to be overlaid upon the background to form the merged image.